package cn.com.io.day20151214.control;

import cn.com.io.day20151214.pojo.Computer;

import java.io.*;
import java.util.ArrayList;

/**
 * 自定义序列化(三)
 */
public class ReplaceTest {
    public static void main(String[] args) throws IOException {
        ObjectOutputStream oos = null;
        ObjectInputStream ois = null;
        try {
            oos = new ObjectOutputStream(new FileOutputStream("replace.txt"));
            Computer computer = new Computer("lenovo","买一赠一",50000);
            oos.writeObject(computer);

            ois =new ObjectInputStream(new FileInputStream("replace.txt"));
            ArrayList list = (ArrayList)ois.readObject();
            System.out.println(list);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            if (oos !=null ){
                oos.close();
            }
            if (ois !=null ){
                ois.close();
            }
        }

    }
}
